<%--
  Created by IntelliJ IDEA.
  User: guo
  Date: 2017/10/31
  Time: 12:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<h1 align="center">商品列表</h1>
<a href="${pageContext.request.contextPath}/add.jsp">增添商品</a>
<div align="center">
    <form action="${pageContext.request.contextPath}/searchServlet">
        <input type="text" name="name" value="${c}">
        <input type="submit" value="搜索">
    </form>
</div>
<div>
    <form action="${pageContext.request.contextPath}/showListServlet">
        <table align="center" width="800px">
            <tr>
                <td>商品序号</td>
                <td>商品名称</td>
                <td>商品市场价格</td>
                <td>操作</td>
            </tr>
            <c:forEach var="p" items="${list}" varStatus="status">
                <c:choose>
                    <c:when test="${status.count%2==0}">
                        <tr style="background-color: aqua">
                            <td>${status.count}</td>
                            <td>${p.pname}</td>
                            <td>${p["market_price"]}</td>
                            <td>
                                <a href="${pageContext.request.contextPath}/showServlet?pid=${p.pid}">修改</a>|
                                <a href="${pageContext.request.contextPath}/deleteServlet?pid=${p.pid}" onclick="return confirm('是否删除')">删除</a>
                            </td>
                        </tr>
                    </c:when>
                    <c:otherwise>
                        <tr style="background-color: royalblue">
                            <td>${status.count}</td>
                            <td>${p.pname}</td>
                            <td>${p["market_price"]}</td>
                            <td>
                                <a href="${pageContext.request.contextPath}/showServlet?pid=${p.pid}">修改</a>|
                                <a href="${pageContext.request.contextPath}/deleteServlet?pid=${p.pid}" onclick="return confirm('是否删除')">删除</a>
                            </td>
                        </tr>
                    </c:otherwise>
                </c:choose>
            </c:forEach>
        </table>
    </form>
</div>
</body>
</html>
